package com.mioto.ld.communication.mqtt.protocol;

import com.mioto.ld.communication.CommunicationEventSource;
import com.mioto.ld.communication.CommunicationPublisher;
import com.mioto.ld.communication.mqtt.protocol.model.Message;
import com.mioto.ld.utils.SpringBeanUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author mioto-qinxj
 * @date 2024/5/16
 * @desc 设备回复处理
 */
@Slf4j
public class ReplyHandleStrategy implements IReceiptHandleStrategy {

    @Override
    public void protocolHandler(Message message)  throws Exception{
        log.info("=============设备消息回复,返回消息到客户端=============");
        //返回消息到客户端
        SpringBeanUtil.getBean(CommunicationPublisher.class).getApplicationEventPublisher()
                .publishEvent(new CommunicationEventSource(message));
    }


}
